<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>后台版本数据管理</title>
    <link rel="stylesheet" href="Public/Plug/layui/css/layui.css" media="all" />
    <style type="text/css">
        .del-his{
            border-bottom: 1px solid #e2e2e2;
            padding-bottom: 20px;
        }
    </style>
</head>

<body>
<div class="admin-main">
    <div style="position: relative;padding: 15px" class="layui-row">
        <div class="del-his">
            <button id="clean" class="layui-btn layui-btn-danger">数据清理</button>
        </div>
        <div style="margin: 10px 0px 0px 20px;" class="layui-row">
            <div class="layui-col-md8">
                <div style="font-size: 18px;font-weight: bold;">操作日志</div>
            </div>
        </div>
        <form class="layui-form" action="">
            <input type="hidden" name="route" value="Operation/index">
            <input type="hidden" name="iActId" value="{I('get.iActId')}">
            <div class="layui-inline">
                <label class="layui-form-label">操作人</label>
                <div class="layui-input-inline">
                    <input type="text" name="search" value="{$search}" placeholder="请输入操作人" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">事件类型</label>
                <div class="layui-input-inline">
                    <select name="type">
                        <option value="">全部</option>
                        <option value="1" {if $type == 1}selected{/if}>{1|logType}</option>
                        <option value="2" {if $type == 2}selected{/if}>{2|logType}</option>
                        <option value="3" {if $type == 3}selected{/if}>{3|logType}</option>
                        <option value="4" {if $type == 4}selected{/if}>{4|logType}</option>
                        <option value="6" {if $type == 6}selected{/if}>{6|logType}</option>
                        <option value="5" {if $type == 5}selected{/if}>{5|logType}</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">日期范围</label>
                <div class="layui-input-inline">
                    <input type="text" name="date" class="layui-input" id="date" placeholder=" - " value="{$date}">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <button class="layui-btn" lay-submit="" lay-filter="search">搜索</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
        <div class="layui-row">
            <div class="layui-col-md12">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th style="width: 40px;">ID</th>
                        <th style="width: 40px;">操作人</th>
                        <th style="width: 50px;">流水号</th>
                        <th style="width: 40px;">操作事件</th>
                        <th>URL</th>
                        <th>SQL</th>
                        <th style="width: 40px;">结果</th>
                        <th style="width: 100px;">操作时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach $log as $k => $val}
                        <tr>
                            <td>{$val.id}</td>
                            <td>{$val.name}</td>
                            <td>{$val.sSerial}</td>
                            <td>{$val.action}</td>
                            <td>{$val.url}</td>
                            <td>{$val.sql|stripcslashes}</td>
                            <td>{$val.result}</td>
                            <td>{$val.createTime}</td>
                        </tr>
                    {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
        {$page}
    </div>
</div>
    <script type="text/javascript" src="Public/Plug/layui/layui.js"></script>
    <script>
        layui.use(['form','laydate'], function() {
            var	form = layui.form,
                $ = layui.jquery,
                laydate = layui.laydate;
            //日期范围
            laydate.render({
                elem: '#date'
                ,range: true
            });

            $("#clean").click(function() {
                layer.confirm('将清理三个月前的历史版本数据？', {
                    btn: ['确定','取消'], //按钮
                    shade: false //不显示遮罩
                }, function(index){
                    var url = "{U('Operation/clean')}";
                    $.get(url,function(data){
                        if(data.type == 0){
                            layer.msg(data.msg, {
                                icon: 2,//失败的表情
                                time: 1500
                            });
                            return;
                        }else{
                            layer.msg(data.msg, {
                                icon: 1,//成功的表情
                                time: 1500
                            });
                        }
                    });
                });
            });

        });
    </script>
</body>

</html>